import { getDicData } from '@/service';
import { useEffect, useState } from 'react';

// 获取数据字典数据
export const useDictDataList = (str: string, fn?: (a: any[]) => void) => {
  const [list, setList] = useState<any>([]);

  useEffect(() => {
    getDicData({ dictClassifyCode: str }).then((res) => {
      const arr = res.data || [];
      setList(arr);
      fn?.(arr);
    });
  }, []);

  return [list, setList, list[0] || []];
};
